// 引入mysql模块
const mysql = require('mysql');
// 创建连接池实例
const db = mysql.createPool({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'root',
  database: 'edudb'

});

const user = {
  name: '张三',
  age: 22
}

//快捷写法
let sql = "insert into user set ?";

db.query(sql, user, (err, result) => {
  if (err) {
    return console.log(err);
  }
  console.log(result.affectedRows);
})